package com.affectu.category;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import org.jboss.seam.annotations.Name;

import com.affectu.common.base.EntityBase;

/**
 * 2008-8-19
 * 
 * @author daniel nathan
 * 
 */
@Entity
@Name("category")
public class Category extends EntityBase {

	private static final long serialVersionUID = 2227441925306810229L;

	private int level;

	@ManyToOne
	@JoinColumn(name = "parentId")
	private Category parent;

	@OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	private List<Category> children = new ArrayList<Category>();

	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}

	public Category getParent() {
		return parent;
	}

	public void setParent(Category parent) {
		this.parent = parent;
	}

	public List<Category> getChildren() {
		return children;
	}

	public void setChildren(List<Category> children) {
		this.children = children;
	}

}
